extends PlayerStatusBase

var wall_jump_time:float = 0.0

func start() ->void:
	wall_jump_time = 0.0
	actor.play_animation("running")
	#Engine.time_scale = 0.3
#func stop() -> void:
	#Engine.time_scale = 1.0
# Called when the node enters the scene tree for the first time.
func run_physics_process(delta:float) -> void:
	wall_jump_time += delta
	var collision_info = actor.move_and_collision_info()
	if collision_info.get("is_on_floor"):
		if actor.velocity.x == 0:
			return change_status("Idle")
		else:
			return change_status("Run")
			
	if collision_info.get("is_on_wall") && actor.can_wall_slide():
		return change_status("WallSlide")
		
# Called every frame. 'delta' is the elapsed time since the previous frame.
func run_process(delta: float) -> void:
	if wall_jump_time < 0.2:
		wall_jump_velocity(delta)
	else:
		common_velocity(delta)
		if actor.velocity.y>0:
			return change_status("Fall")

func wall_jump_velocity(delta:float)->void:
	move_y(delta)
		
	var wall_direction = actor.get_wall_normal().x
	var direction := actor.get_direction()
	if direction == 0 or direction * wall_direction > 0:
		move_toward_x(5*delta,2.0,wall_direction)
		actor.face_direction(wall_direction)
	else:
		move_toward_x(5*delta,0.5,direction)
		actor.face_direction(direction)
